package day10;

public class Person {
    public String name;
    public int age;
    public void keepPet(Animal animal,String something){
        if(animal instanceof Dog d){
            System.out.println("年龄为"+age+"的老"+name.charAt(0)+"养了一只"+d.color+"颜色的狗");
            d.eat(something);
        }
        else if(animal instanceof Cat c){
            System.out.println("年龄为"+age+"的老"+name.charAt(0)+"养了一只"+c.color+"颜色的猫");
            c.eat(something);
        }
    }

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
